/*     */ package com.iris.egrant.web.struts2.tags;
/*     */
/*     */ import com.iris.egrant.component.model.HelpTips;
/*     */ import com.iris.egrant.component.service.HelpTipsService;
/*     */ import com.iris.egrant.remote.http.service.ServiceFactory;
/*     */ import com.iris.egrant.app.utils.IrisStringUtils;
/*     */ import freemarker.template.Configuration;
/*     */ import freemarker.template.Template;
/*     */ import java.io.Writer;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.jsp.JspException;
/*     */ import javax.servlet.jsp.tagext.BodyTagSupport;
/*     */ import org.springframework.context.i18n.LocaleContextHolder;
/*     */ import org.springframework.web.context.WebApplicationContext;
/*     */ import org.springframework.web.context.support.WebApplicationContextUtils;
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */
/*     */ public class HelpTipsTag
/*     */   extends BodyTagSupport
/*     */ {
/*     */   private static final long serialVersionUID = 1077194066541229822L;
/*  31 */   private String key = "";
/*     */
/*  33 */   private String locale = null;
/*     */
/*  35 */   private String cacheable = "false";
/*     */
/*  37 */   private String id = "";
/*     */
/*     */
/*  40 */   private String className = "tipsBox";
/*     */
/*     */
/*     */   public String getId() {
/*  44 */     return this.id;
/*     */   }
/*     */
/*     */
/*     */   public void setId(String id) {
/*  49 */     this.id = id;
/*     */   }
/*     */
/*     */   public String getCacheable() {
/*  53 */     return this.cacheable;
/*     */   }
/*     */
/*     */   public void setCacheable(String cacheable) {
/*  57 */     this.cacheable = cacheable;
/*     */   }
/*     */
/*     */   public String getLocale() {
/*  61 */     if (IrisStringUtils.isNullOrBlank(this.locale)) {
/*  62 */       return LocaleContextHolder.getLocale().toString();
/*     */     }
/*  64 */     return this.locale;
/*     */   }
/*     */
/*     */   public void setLocale(String locale) {
/*  68 */     this.locale = locale;
/*     */   }
/*     */
/*     */
/*     */   public int doStartTag() throws JspException {
/*  73 */     WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.pageContext.getServletContext());
/*     */
/*  75 */     ServiceFactory serviceFactory = (ServiceFactory)context.getBean("serviceFactory");
/*  76 */     Configuration cptFreemarkereConfiguration = (Configuration)context.getBean("cptFreemarkereConfiguration");
/*     */
/*     */
/*     */     try {
/*  80 */       HelpTips helpTips = ((HelpTipsService)serviceFactory.getService(HelpTipsService.class)).findHelpTipsByKey(this.key, this.cacheable);
/*     */
/*  82 */       Map<String, Object> rootMap = new HashMap<String, Object>();
/*     */
/*  84 */       String res = (String)this.pageContext.getAttribute("res");
/*  85 */       String ctx = (String)this.pageContext.getAttribute("ctx");
/*  86 */       String title = "";
/*  87 */       String content = "";
/*  88 */       rootMap.put("res", res);
/*  89 */       rootMap.put("ctx", ctx);
/*  90 */       rootMap.put("id", this.id);
/*  91 */       rootMap.put("key", this.key);
/*     */
/*  93 */       if (helpTips != null) {
/*  94 */         if ("zh_CN".equals(getLocale())) {
/*  95 */           title = helpTips.getZhCnTitle();
/*  96 */           content = helpTips.getZhCnContent();
/*  97 */         } else if ("en_US".equals(getLocale())) {
/*  98 */           title = helpTips.getEnUsTitle();
/*  99 */           content = helpTips.getEnUsContent();
/*     */         } else {
/* 101 */           title = helpTips.getZhTwTitle();
/* 102 */           content = helpTips.getZhTwContent();
/*     */         }
/*     */       }
/*     */
/* 106 */       rootMap.put("title", title);
/* 107 */       rootMap.put("content", (content == null) ? "" : content);
/*     */
/* 109 */       String hidden_tip = "";
/* 110 */       String display_tip = "";
/* 111 */       if ("zh_TW".equals(this.locale)) {
/* 112 */         hidden_tip = "隱藏提示";
/* 113 */         display_tip = "展開提示";
/* 114 */       } else if ("en_US".equals(this.locale)) {
/* 115 */         hidden_tip = "Hide";
/* 116 */         display_tip = "Display";
/*     */       } else {
/* 118 */         hidden_tip = "隐藏提示";
/* 119 */         display_tip = "展开提示";
/*     */       }
/*     */
/* 122 */       rootMap.put("hidden_tip", hidden_tip);
/* 123 */       rootMap.put("display_tip", display_tip);
/* 124 */       rootMap.put("className", this.className);
/*     */
/* 126 */       Template template = cptFreemarkereConfiguration.getTemplate("helpTips.ftl", "utf-8");
/*     */
/*     */
/* 129 */       template.process(rootMap, (Writer)this.pageContext.getOut());
/*     */     }
/* 131 */     catch (Exception e) {
/* 132 */       throw new JspException(e);
/*     */     }
/*     */
/* 135 */     return 0;
/*     */   }
/*     */
/*     */   public String getKey() {
/* 139 */     return this.key;
/*     */   }
/*     */
/*     */   public void setKey(String key) {
/* 143 */     this.key = key;
/*     */   }
/*     */
/*     */   public String getClassName() {
/* 147 */     return this.className;
/*     */   }
/*     */
/*     */   public void setClassName(String className) {
/* 151 */     this.className = className;
/*     */   }
/*     */ }


/* Location:              D:\文件kjt\WEB-INF\lib\egrant-core-2.2.20240205.1659.jar!\com\iris\egrant\web\struts2\tags\HelpTipsTag.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */